<html>
<head><meta charset="utf-8"><title>What if cranelift can&#x27;t do Vec3s? · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html">What if cranelift can&#x27;t do Vec3s?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225626407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225626407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225626407">(Feb 08 2021 at 23:46)</a>:</h4>
<p>So, "Vec3" here is a placeholder for "vectors of an irregular lane count that is not a power of 2".<br>
In <a href="https://github.com/rust-lang/rust/pull/80652">https://github.com/rust-lang/rust/pull/80652</a> we introduced a monomorphization error for those to <code>repr_simd</code>.<br>
<a href="https://github.com/WebAssembly/flexible-vectors/">https://github.com/WebAssembly/flexible-vectors/</a> is probably going to be a thing someday so I would EXPECT these vectors to become a thing in Cranelift, but at the moment it isn't very far along and it might be pretty limited.</p>
<p>Some discussion of this is here <a href="https://github.com/bjorn3/rustc_codegen_cranelift/issues/1136">https://github.com/bjorn3/rustc_codegen_cranelift/issues/1136</a><br>
Worth thinking about what our options are!</p>



<a name="225629952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225629952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225629952">(Feb 09 2021 at 00:30)</a>:</h4>
<p>It seems like most of the implementations of actual vectors with non-power-of-2 sizes are a bit different than the "next power of 2 up" model that seems to be assumed by e.g. the vek code and that LLVM uses for these. Am I incorrect there?</p>



<a name="225630309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225630309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225630309">(Feb 09 2021 at 00:35)</a>:</h4>
<p>How important is having <code>Vec3</code> be part of this simd-portable crate?</p>



<a name="225630417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225630417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225630417">(Feb 09 2021 at 00:36)</a>:</h4>
<p>*crate</p>



<a name="225630572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225630572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225630572">(Feb 09 2021 at 00:38)</a>:</h4>
<p>I think it would be completely appropriate to use next power of 2 up on platforms that only have powers of two, and do it "the right way" on platforms that support it</p>



<a name="225630673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225630673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225630673">(Feb 09 2021 at 00:39)</a>:</h4>
<p>I personally wouldn't consider it critically important because this is "portable SIMD" and at the moment we can't actually target any architectures that support non-power-of-two sizes. But even then I think it's a useful abstraction</p>



<a name="225631158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631158">(Feb 09 2021 at 00:46)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> I'm inclined to agree. It's already a major win to get SIMD processing from a single thread.  I would have to consider more, but I suspect that much of the win also depends on the ability to avoid incremental branching.  With a datatype of say 24-bit none of the operations work "off the rack".  Everything becomes custom. With that customization comes more complexity in the logic... more chances of branching and other sub-optimal data "work-flows".  All this to say, trade-offs the user of the crate will be best equipped to manage?... at least until more is learned about the performance and final design of the crate?</p>



<a name="225631407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631407">(Feb 09 2021 at 00:49)</a>:</h4>
<p>As far as "how important", it's not devastatingly important but establishing priorities is part of the game, and if we don't deal with !(2^N) vectors now, we're kind of kicking the can down the road more than anything. And this is already considered a desirable feature by SIMD authors, the classical example being a 3D dot product.</p>



<a name="225631489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631489">(Feb 09 2021 at 00:50)</a>:</h4>
<blockquote>
<p>I think it would be completely appropriate to use next power of 2 up on platforms that only have powers of two, and do it "the right way" on platforms that support it</p>
</blockquote>
<p>This feels rather nonportable. Given the discussions around NaN architecture dependence being unacceptable, this feels like a way more significant departure between architectures that's much more liable to cause people to write nonportable code.</p>



<a name="225631555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631555">(Feb 09 2021 at 00:51)</a>:</h4>
<p>I'm curious, what would be non portable about it?</p>



<a name="225631642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631642">(Feb 09 2021 at 00:52)</a>:</h4>
<p>If the behavior is drastically different depending on architecture that feels like a very non-"portable simd" thing, no?</p>



<a name="225631654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631654">(Feb 09 2021 at 00:52)</a>:</h4>
<p>It's exactly what LLVM does, but we may need to handle it at the rust level or maybe even MIR lowering instead of in cranelift</p>



<a name="225631669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631669">(Feb 09 2021 at 00:52)</a>:</h4>
<p>the question is if it's different vs. observably different</p>



<a name="225631703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631703">(Feb 09 2021 at 00:53)</a>:</h4>
<p>Great question.  It would just require more vectors from one platform to the next. No?</p>



<a name="225631738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631738">(Feb 09 2021 at 00:53)</a>:</h4>
<p>in a strict sense, our API will be behaviorally different based on architecture already but in nonobservable ways.</p>



<a name="225631807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631807">(Feb 09 2021 at 00:54)</a>:</h4>
<p>What is considered observable? Speed?</p>



<a name="225631833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631833">(Feb 09 2021 at 00:55)</a>:</h4>
<p>Observable would be resulting in different values</p>



<a name="225631857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631857">(Feb 09 2021 at 00:55)</a>:</h4>
<p>yeah i definitely wouldn't consider speed observable here.</p>



<a name="225631936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225631936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225631936">(Feb 09 2021 at 00:56)</a>:</h4>
<p>Cool.  Just level-setting my understanding of what is being described.</p>



<a name="225632092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632092">(Feb 09 2021 at 00:58)</a>:</h4>
<p>I think it behaving like <code>[T; N]</code> vs <code>[T; N.next_power_of_two()]</code> (where the T's over N are uninit) is observable. I also expect if we support this where all of these behave that way, people will definitely write code under that assumption</p>



<a name="225632133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632133">(Feb 09 2021 at 00:58)</a>:</h4>
<p>So the concern is that placing a 24-bit value in a 32-bit lane could generate different values compared to a system that places 24-bit value in a 24-bit lane. Yes?</p>



<a name="225632180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632180">(Feb 09 2021 at 00:58)</a>:</h4>
<p>we're taling about stuff like <code>Simd&lt;f32, 3&gt;</code> rather than non power of two bit widths, i think</p>



<a name="225632309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632309">(Feb 09 2021 at 01:00)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> what is observable about that, other than the size of the type?</p>



<a name="225632388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632388">(Feb 09 2021 at 01:01)</a>:</h4>
<p>Like, it's one thing if it behaves a certain way on some architectures and another on others out of the gate, but if it were to stabilize and behave consistently on all supported architectures and we later plan on changing it in major ways that will cause code to either fail to compile or fail to run...</p>
<p>Especially because this is just not actually a supported thing on the architectures we'd be adding it for, and we know we later want to support arches that do this differently.</p>



<a name="225632393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632393">(Feb 09 2021 at 01:01)</a>:</h4>
<p>It would mean that you can't transmute between arrays and vectors, but that doesn't mean it's not portable</p>



<a name="225632501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632501">(Feb 09 2021 at 01:02)</a>:</h4>
<p>Sorry, maybe something is unclear, but if it rounds up to the next power of two, the public API would still operate entirely on the reduced lane set</p>



<a name="225632546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632546">(Feb 09 2021 at 01:03)</a>:</h4>
<p>Which is precisely what LLVM does to handle non-native vector sizes</p>



<a name="225632800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632800">(Feb 09 2021 at 01:05)</a>:</h4>
<p>I know, but the layout would be entirely different. While it's true that there are existing types with different layout guarantees on different targets, they all pretty much have to do with #[cfg(target_pointer_width)], and where possible for has made this identical, no?</p>
<p>I think it's realistic to assume people will write code assuming the layout is "round up to PoT" if we stabilize these working this way on targets that don't support them, don't have any that don't work that way, and call it portable simd</p>



<a name="225632900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632900">(Feb 09 2021 at 01:06)</a>:</h4>
<p>It seems bizarre to stabilize something that will have such drastically different layout considerations on future targets when it doesn't exist on current targets, when we could just... not support it until it comes up on the targets that actually behave that way.</p>



<a name="225632944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632944">(Feb 09 2021 at 01:07)</a>:</h4>
<p>Like, we're deliberately going out of our way to introduce a thing with non-portable behaviors that doesn't otherwise exist (in this api, yet)</p>



<a name="225632968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632968">(Feb 09 2021 at 01:07)</a>:</h4>
<p>eh, I think that's making assumptions re: how data gets loaded into and stored from vector registers that might not hold or might just already be a concern anyways.</p>



<a name="225632992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225632992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225632992">(Feb 09 2021 at 01:07)</a>:</h4>
<p>I still fail to see why that's non-portable, I think.  Vectors will already have different alignments on different architectures</p>



<a name="225633001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225633001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225633001">(Feb 09 2021 at 01:07)</a>:</h4>
<p>That.</p>



<a name="225633078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225633078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225633078">(Feb 09 2021 at 01:08)</a>:</h4>
<p>So we probably need to spend some time looking more closely at vector alignment and layout between arches and what that actually means for us.</p>



<a name="225633126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225633126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225633126">(Feb 09 2021 at 01:09)</a>:</h4>
<p>Perhaps there should be functions for loading vectors from aligned and unaligned element types, which can take the layout into consideration</p>



<a name="225633128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225633128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225633128">(Feb 09 2021 at 01:09)</a>:</h4>
<p>if the answer to the question is "how do non-power of two vectors behave" is "round up to next power of two and discard the excess" for all initially supported targets, I think that's going to be hard to change if later we want to.</p>



<a name="225633208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225633208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225633208">(Feb 09 2021 at 01:10)</a>:</h4>
<p>I think the answer is "use std::mem::size_of" because it could be radically different between any given architectures</p>



<a name="225633301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225633301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225633301">(Feb 09 2021 at 01:11)</a>:</h4>
<p>I don't even think it's a breaking change to change the layout of a vector in the future?</p>



<a name="225633549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225633549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225633549">(Feb 09 2021 at 01:14)</a>:</h4>
<p>for FFI it is, definitely, and until safe_transmute exists if we expect these types to be transumted (I would, since we know that people will want to use them with core::arch intrinsics) that is too. In particular I see a lot of ways that people could easily end accidentally up writing nonportable code using this because they send things to the GPU and such.</p>
<p>I know you can just say "should have read the docs better since you're writing unsafe code" but it just makes very little sense to be to introduce something like this when nothing currently supported actually has it</p>



<a name="225633700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225633700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225633700">(Feb 09 2021 at 01:16)</a>:</h4>
<p>Well I wouldn't say nothing has it, vek already showed that it's useful regardless of architecture, but I agree that if we decide we don't want to support it we can and it's probably ok</p>



<a name="225633717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225633717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225633717">(Feb 09 2021 at 01:16)</a>:</h4>
<p>Ah, I meant no architecture we currently target supports it directly.</p>



<a name="225634012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225634012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225634012">(Feb 09 2021 at 01:20)</a>:</h4>
<p>Rust is already very conservative about layout guarantees, and already has types (<code>usize</code>) that change their layout across architectures. I don't see how this is any different. Just make it clear what is and is not a stable guarantee</p>



<a name="225634033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225634033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225634033">(Feb 09 2021 at 01:20)</a>:</h4>
<p>almost a joke but not really: hey Rust has a GPGPU target doesn't it? GPUs support vec3s :^)</p>



<a name="225634648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225634648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225634648">(Feb 09 2021 at 01:30)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span>   - I agree they could generate different values.  If we went "next ^2" hoping to change that in the future, that could be difficult to replicate.  The way I'm looking at it there are two sources of the gap: the values hosted on the bits, and the operations that need to be adapted.  Emulating 24-bit data values on a 32-bit lane I expect is doable and pretty straightforward.  It's running the operations on them that will create a bunch of work (over-flow, sign-bit-dependent ops, and wrap-around).  If I were a user (even 3D for now) and was determined to get as much as I could into a single vector (increase the lane count per vec), I would save that for very specialized/hot locations in my data-transformation workflow... because without built-in support from the operations, how exactly I chose to make all these decisions is not something I could expect to be a norm.  </p>
<p>If we implement too early, we risk generating values that turn out to be just plain wrong.  Let that be up to the user for now.  </p>
<p>For me I, I value transparency, reliability and solid performance in that order.  Without the first two, I can't do much to make my app more performant.</p>



<a name="225634771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225634771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225634771">(Feb 09 2021 at 01:32)</a>:</h4>
<p>we don't handle overflow.</p>



<a name="225634902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225634902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225634902">(Feb 09 2021 at 01:34)</a>:</h4>
<p>Rust integers by default wrap on overflow, same as the CPU does. If this happens in scalar code in debug mode, they panic, but we have decided to not make that a feature of our API, and in any case it differs in release mode.</p>



<a name="225635036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225635036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225635036">(Feb 09 2021 at 01:35)</a>:</h4>
<p>So, my problem (insofar as I have a "problem") is that so far I have not been convinced that we do not have any unique problems with f32x3 that are not already raised by u8x8 SIMD operations on Intel CPUs.</p>



<a name="225635043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225635043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225635043">(Feb 09 2021 at 01:35)</a>:</h4>
<blockquote>
<p>we don't handle overflow.</p>
</blockquote>
<p>Not sure if you are referring to what I posted.  But your point I believe describes where the two approaches can diverge: In the 32-bit lane hosting 24-bit data, we would have to "emulate" overflow to keep the two approaches from generating different values.</p>



<a name="225635142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225635142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225635142">(Feb 09 2021 at 01:36)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> or even smaller vectors. We support u8x2</p>



<a name="225635149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225635149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225635149">(Feb 09 2021 at 01:37)</a>:</h4>
<p>We are not discussing vector lane bitwidths differing from used vector lane bitwidths, we are discussing vector register lane counts differing from used vector lanes.</p>



<a name="225635181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225635181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225635181">(Feb 09 2021 at 01:37)</a>:</h4>
<p>We have no compiler support for u24 at the moment, a fact that has caused us some grief but we are somewhat resigned to the reality of. ^^;</p>



<a name="225635702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225635702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225635702">(Feb 09 2021 at 01:45)</a>:</h4>
<p>Oh! Got it. My bad, apologies for mixing up T for N in how I was thinking about <code>[T; N]</code> vs <code>[T; N.next_power_of_two()]</code>.</p>



<a name="225635828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225635828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225635828">(Feb 09 2021 at 01:47)</a>:</h4>
<p>Why is the size of u8x3 4 bytes on x86-64?</p>



<a name="225635948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225635948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225635948">(Feb 09 2021 at 01:49)</a>:</h4>
<p><span class="user-mention" data-user-id="388128">@Edmund Cape</span>  It is completely understandable.</p>



<a name="225636080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225636080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225636080">(Feb 09 2021 at 01:51)</a>:</h4>
<p>That's... interesting. <span class="user-mention" data-user-id="312331">@Caleb Zulawski</span></p>



<a name="225636149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225636149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225636149">(Feb 09 2021 at 01:52)</a>:</h4>
<p>I have a bad feeling that rustc just rounds all repr(simd) to the next power of two to be safe</p>



<a name="225636188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225636188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225636188">(Feb 09 2021 at 01:52)</a>:</h4>
<p>lol.</p>



<a name="225636211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225636211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225636211">(Feb 09 2021 at 01:53)</a>:</h4>
<p>y'all are gonna find lots of bugs with me around. :^)</p>



<a name="225636282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225636282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225636282">(Feb 09 2021 at 01:54)</a>:</h4>
<p>So I think I'm confident that I would like to support non-power-of-two but I'm also confident it may not be practical any time soon</p>



<a name="225636928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225636928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edmund Cape <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225636928">(Feb 09 2021 at 02:04)</a>:</h4>
<p>When lane count available from lane count used differ, when can the value of the vectorized computation differ?  I don't see vertical computations changing.  <span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> do you?  Loading and unloading data where every 4th element needs to be skipped seems easy enough.  The issue would be with any horizontal computations. Would those computations be easy to unify?</p>



<a name="225637120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225637120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225637120">(Feb 09 2021 at 02:07)</a>:</h4>
<p>I think horizontal ops are accomplished by appropriately filling the unused lanes</p>



<a name="225637267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225637267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225637267">(Feb 09 2021 at 02:09)</a>:</h4>
<p>One thing I'm now confused about is why does the size of a non-native vector sometimes, but not always, round up?  Why is the size of u8x2 2 (not a vector size), u8x3 is 4 (also not a vector size) but u32x3 is 16 (an SSE vector)</p>



<a name="225637342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225637342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225637342">(Feb 09 2021 at 02:10)</a>:</h4>
<p>have we considered the possibility that the Code is Wrong</p>



<a name="225637541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225637541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225637541">(Feb 09 2021 at 02:12)</a>:</h4>
<p>I'm fairly sure that's what it is <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="225637655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225637655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225637655">(Feb 09 2021 at 02:14)</a>:</h4>
<p>So the question is, should it always be a valid vector size? Is there some other reason it's rounded up? Is there no good reason?</p>



<a name="225637812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225637812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225637812">(Feb 09 2021 at 02:16)</a>:</h4>
<p>Without going to deeply into the details of various SIMD implementations, I would expect the size of the rust type to be the size of the actual used numbers of lanes, and that size to be rounded up to the next supported vector size by the backend.</p>



<a name="225637862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225637862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225637862">(Feb 09 2021 at 02:17)</a>:</h4>
<p>The thing that's particularly concerning is that the layout is determined before even getting to codegen, does it even depend on architecture?</p>



<a name="225637929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225637929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225637929">(Feb 09 2021 at 02:18)</a>:</h4>
<p>all wonderful questions!</p>



<a name="225637954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225637954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225637954">(Feb 09 2021 at 02:18)</a>:</h4>
<p>Why does repr(simd) pass vectors by reference?</p>



<a name="225638183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225638183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225638183">(Feb 09 2021 at 02:23)</a>:</h4>
<p>well...!</p>



<a name="225638190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225638190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225638190">(Feb 09 2021 at 02:23)</a>:</h4>
<p>...a good question!</p>



<a name="225638210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225638210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225638210">(Feb 09 2021 at 02:23)</a>:</h4>
<p>Oh, I figured out the answer to the last question</p>



<a name="225638215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225638215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225638215">(Feb 09 2021 at 02:23)</a>:</h4>
<p>!</p>



<a name="225638285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225638285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225638285">(Feb 09 2021 at 02:24)</a>:</h4>
<p>If you compile for AVX, vectors (in general, not in rust) are allowed to be passed via ymm register.  This would make target_feature unusable</p>



<a name="225638304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225638304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225638304">(Feb 09 2021 at 02:25)</a>:</h4>
<p>In rust they are always passed by reference to allow crossing feature support boundaries</p>



<a name="225638334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225638334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225638334">(Feb 09 2021 at 02:25)</a>:</h4>
<p>So I think this is unrelated to the size of the vector rounding up.</p>



<a name="225638347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225638347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225638347">(Feb 09 2021 at 02:25)</a>:</h4>
<p>hmm wait.</p>



<a name="225638858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225638858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225638858">(Feb 09 2021 at 02:33)</a>:</h4>
<p>right, I see now.</p>



<a name="225639054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225639054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225639054">(Feb 09 2021 at 02:36)</a>:</h4>
<p>Maybe time to find the layout code that rounds up the size, and blame it? Maybe it is just wrong...</p>



<a name="225639068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225639068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225639068">(Feb 09 2021 at 02:36)</a>:</h4>
<p>I searched issues and prs but didn't see anything right away</p>



<a name="225644721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225644721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225644721">(Feb 09 2021 at 04:23)</a>:</h4>
<p>So, this appears to be where the size is actually determined:<br>
<a href="https://github.com/rust-lang/rust/blob/bb587b1a1737738658d2eaecd4c8c1cab555257a/compiler/rustc_middle/src/ty/layout.rs#L762">https://github.com/rust-lang/rust/blob/bb587b1a1737738658d2eaecd4c8c1cab555257a/compiler/rustc_middle/src/ty/layout.rs#L762</a></p>
<p>The size is chosen based on the alignment</p>



<a name="225645506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225645506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225645506">(Feb 09 2021 at 04:39)</a>:</h4>
<p>This appears to be the original commit specifying the layout of vectors: <a href="https://github.com/rust-lang/rust/commit/fe48a4af8403289ebc811884964fc4ef91f6bc09">https://github.com/rust-lang/rust/commit/fe48a4af8403289ebc811884964fc4ef91f6bc09</a></p>



<a name="225645727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225645727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225645727">(Feb 09 2021 at 04:44)</a>:</h4>
<p>Also, playing around with clang types such as <code>typedef char vec __attribute__((ext_vector_type(3)));</code> I seem to get the same layout as rustc.  u8x3 is 4 bytes, etc</p>



<a name="225646053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225646053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225646053">(Feb 09 2021 at 04:52)</a>:</h4>
<p>hum.</p>



<a name="225718425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225718425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225718425">(Feb 09 2021 at 16:43)</a>:</h4>
<p>I filed this bug. <a href="https://github.com/rust-lang/rust/issues/81931">https://github.com/rust-lang/rust/issues/81931</a></p>



<a name="225718945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225718945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225718945">(Feb 09 2021 at 16:46)</a>:</h4>
<p>Yeah I was focusing more on the size, but the alignment thing is weird too</p>



<a name="225719032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225719032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225719032">(Feb 09 2021 at 16:46)</a>:</h4>
<p>It's a little odd because I'd expect llvm to at least emit movups instead</p>



<a name="225719817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225719817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225719817">(Feb 09 2021 at 16:51)</a>:</h4>
<p>imo if the size is wrong but the alignment is correct then we can make that work, but if the alignment is wrong then we have serious problems even if the size is correct.</p>



<a name="225720012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225720012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225720012">(Feb 09 2021 at 16:53)</a>:</h4>
<p>Agreed. Though perhaps I'll file a complementary issue for the size later today</p>



<a name="225720529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225720529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225720529">(Feb 09 2021 at 16:56)</a>:</h4>
<p>Mm, I would add the data into that issue and your reasoning for why size is also relevant, and if it actually is another issue we can split it out, but I suspect if both need to be addressed then both can/will be addressed at the same time.</p>



<a name="225724031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225724031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225724031">(Feb 09 2021 at 17:16)</a>:</h4>
<p>They're definitely related, but it <em>might</em> be a separate issue?  Perhaps not</p>



<a name="225728794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225728794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225728794">(Feb 09 2021 at 17:48)</a>:</h4>
<p>Given that size is dependent on alignment, based on what you said, I think kinda not?</p>



<a name="225729849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/225729849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#225729849">(Feb 09 2021 at 17:54)</a>:</h4>
<p>Good point.</p>



<a name="226759142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226759142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226759142">(Feb 18 2021 at 03:03)</a>:</h4>
<blockquote>
<p>Like the Intel386 architecture, the AMD64 architecture in general does not re-quire all data accesses to be properly aligned. Misaligned data accesses are slower than aligned accesses but otherwise behave identically.  The only exceptions are that <code>__m128</code>, <code>__m256</code> and <code>__m512</code> must always be aligned properly.</p>
</blockquote>
<p>Well.</p>



<a name="226759212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226759212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226759212">(Feb 18 2021 at 03:04)</a>:</h4>
<p>Yeah x86-64 doesn't really care about alignment at all (though if you use explicitly aligned loads they will fail/do bad things if your data is unaligned)</p>



<a name="226759220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226759220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226759220">(Feb 18 2021 at 03:04)</a>:</h4>
<p>Aarch64 does care about alignment afaik</p>



<a name="226759890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226759890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226759890">(Feb 18 2021 at 03:17)</a>:</h4>
<p>yeah, unaligned loads are still pretty fast on aarch64 (even if they're actually unaligned — they're very cheap, almost free, if they're actually aligned), but you need to explicitly use unaligned loads</p>



<a name="226759908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226759908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226759908">(Feb 18 2021 at 03:17)</a>:</h4>
<p>that's true for at least armv7 as well actually</p>



<a name="226759965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226759965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226759965">(Feb 18 2021 at 03:18)</a>:</h4>
<p>Won't armv7 error on unaligned loads?</p>



<a name="226760205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226760205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226760205">(Feb 18 2021 at 03:22)</a>:</h4>
<p>depends on the size of the value and some other stuff</p>



<a name="226760515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226760515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226760515">(Feb 18 2021 at 03:28)</a>:</h4>
<blockquote>
<p>In Armv7-A and Armv7-R ... If alignment checking is enabled, all unaligned word and halfword transfers cause an alignment exception. If disabled, unaligned accesses are permitted for the LDR, LDRH, STR, STRH, LDRSH, LDRT, STRT, LDRSHT, LDRHT, STRHT, and TBH instructions. Other data-accessing instructions always cause an alignment exception for unaligned data. For STRD and LDRD, the specified address must be word-aligned.</p>
</blockquote>
<p>But note that if even using the unaligned operations isn't really that slow on arm. also, rust will use these instructions fro read_unaligned, so presumably we don't support the case where you enable alignemnet checking (requires flipping a bit in the system control register)</p>



<a name="226760757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226760757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226760757">(Feb 18 2021 at 03:33)</a>:</h4>
<p>rust makes working with unaligned data painful though, and apis like align_to encourage writig bulk processing algorithms by handling the head and tail with per-byte operations (for aligning &amp;[u8] to some T, e.g. usize or a vector), which is generally going to be worse for performance than e.g. doing an unaligned reads for the head and tail</p>



<a name="226760838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226760838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226760838">(Feb 18 2021 at 03:34)</a>:</h4>
<p>(this is a rant for another day though)</p>



<a name="226774494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/What%20if%20cranelift%20can%27t%20do%20Vec3s%3F/near/226774494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/What.20if.20cranelift.20can&#x27;t.20do.20Vec3s.3F.html#226774494">(Feb 18 2021 at 07:42)</a>:</h4>
<p>No I was noticing the claim that the vector types <strong>must</strong> be aligned and thought that was interesting.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>